# 用Python内置的csv模块
import csv,time,unittest
from selenium import webdriver
from selenium.webdriver.common.by import By
from ddt import ddt, data, unpack


def read_csv(file_path):
    list = []
    with open(file_path,'r',encoding='utf-8') as f:
        datas = csv.reader(f)
        next(datas)
        for i in datas:
            list.append(i)
        return list


@ddt
class Test_126(unittest.TestCase):
    file_path = r'D:\gao1\PythonProject4\csva.csv'
    # 初始化
    def setUp(self):
        self.driver = webdriver.Edge()
        self.driver.get("https://www.doubao.com/chat/")
        self.driver.maximize_window()
        time.sleep(5)

    def tearDown(self):
        # 关闭浏览器
        time.sleep(3)
        self.driver.quit()

    @data(*read_csv(file_path))
    @unpack
    def test_doubao(self,name):
        self.driver.find_element(By.XPATH, '//*[@id="chat-route-layout"]/div/main/div/div/div[2]/div/div/div[2]/div[2]/div[2]/div[2]/div[2]/div[1]/div/textarea').send_keys(name)
        time.sleep(5)



if __name__ == "__main__":
    unittest.main()